package com.shop.admin.controller.Admin;

import com.shop.entity.dto.AdminOrders.AdminOrdersGetDetailDto;
import com.shop.entity.dto.AdminOrders.AdminOrdersListDto;
import com.shop.entity.dto.AdminOrders.AdminOrdersRemoveDto;
import com.shop.entity.dto.AdminOrders.AdminOrdersRestoreDto;
import com.shop.entity.pojo.OrdersDetail;
import com.shop.admin.service.OrdersDetailService;
import com.shop.admin.service.OrdersService;
import com.shop.utils.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/orders")
@Slf4j
public class AdminOrdersController {

    @Autowired
    private OrdersService ordersService;
    @Autowired
    private OrdersDetailService ordersDetailService;

    @PostMapping("/get_orders_list")
    public Result ordersList(@RequestBody AdminOrdersListDto dto){
        log.info("后台管理-订单管理");
        return ordersService.getAdminOrdersList(dto);
    }

    @PostMapping("/get_orders_detail")
    public Result<List<OrdersDetail>> ordersDetailList(@RequestBody AdminOrdersGetDetailDto dto){
        log.info("后台管理-订单详情");
        return ordersDetailService.getOrdersDetail(dto);
    }

    @PostMapping("/remove_orders")
    public Result removeOrders(@RequestBody AdminOrdersRemoveDto dto){
        log.info("后台管理-删除订单");
        return ordersService.delOneOrders(dto);
    }

    @PostMapping("restore_orders")
    public Result restoreOrders(@RequestBody AdminOrdersRestoreDto dto){
        log.info("后台管理恢复订单");
        return ordersService.restoreOrders(dto);
    }

}
